import {defineStore} from 'pinia'

export const useAside = defineStore('main',{
    state:()=>({
        // 控制侧边栏展开变量
        isCollapse:true,
        // 面包屑数据
        currentMenu:null,
        tabList:[
            {
                path: "/",
                name: "home",
                label: "首页",
                icon: "House",
                url: "Home/Home",
            },
        ]
    }),
    actions:{
         // 控制侧边栏展开方法
        updateIsCollapse(){
            this.isCollapse = !this.isCollapse

        },
        // 给赋值面包屑数据
        selectMenu(val){
            if(val.name == 'home'){
                this.currentMenu = null
            }else{
                this.currentMenu = val

                let result = this.tabList.findIndex(item => item.name === val.name)
                result == -1 ? this.tabList.push(val) : '' 
            }
        },
        // 删除tag标签
        closeTag(val){
            let res= this.tabList.findIndex(item=>item.name === val.name)
            this.tabList.splice(res,1)
        }
    },
    persist: true,
})